<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>
        小程序商城管理平台
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../css/x-admin.css" media="all">
</head>
<style>
    table {
        margin: auto;
        line-height: 45px;
        font-size: 20px;
        font-family: 幼圆;
    }
    #a{
        text-align: center;
        font-family: 华文新魏;
        font-size: 30px;
    }
    #b{
        position:fixed;
        bottom:0;
        right:0;
    }

     .black_overlay{
         display: none;
         position: absolute;
         top: 0%;
         left: 0%;
         width: 100%;
         height: 100%;
         background-color: black;
         z-index:1001;
         -moz-opacity: 0.8;
         opacity:.80;
         filter: alpha(opacity=88);
     }
    .white_content {
        display: none;
        position: absolute;
        top: 7%;
        left: 25%;
        width: 35%;
        height: 75%;
        padding: 20px;
        border: 10px solid orange;
        background-color: white;
        z-index:1002;
        overflow: auto;
    }
    #light{
        line-height: 50px;

    }
</style>
<body>
<div class="layui-layout layui-layout-admin">
    <div class="layui-header header header-demo">
        <div class="layui-main">
            <a class="logo" href="index.html">
                一站式商城管理平台
            </a>
            <ul class="layui-nav" lay-filter="">
                <li class="layui-nav-item"><img src="../images/logo.png" class="layui-circle" style="border: 2px solid #A9B7B7;" width="35px" alt=""></li>
                <li class="layui-nav-item">
                    <a href="javascript:;">admin</a>
                    <dl class="layui-nav-child"> <!-- 二级菜单 -->
                        <dd><a href="">个人中心</a></dd>
                        <dd><a href="../logout">退出</a></dd>
                    </dl>
                </li>
                <!-- <li class="layui-nav-item">
                  <a href="" title="消息">
                      <i class="layui-icon" style="top: 1px;">&#xe63a;</i>
                  </a>
                  </li> -->
                <li class="layui-nav-item x-index"><a th:href="@{'../index'}">首页</a></li>
            </ul>
        </div>
    </div>
    <div class="layui-side layui-bg-black x-side">
        <div class="layui-side-scroll">
            <ul class="layui-nav layui-nav-tree site-demo-nav" lay-filter="side">
                <li class="layui-nav-item">
                    <a class="javascript:;" href="javascript:;">
                        <i class="layui-icon" style="top: 3px;">&#xe607;</i><cite>会员管理</cite>
                    </a>
                    <dl class="layui-nav-child">
                        <dd class="">
                        <dd class="">
                            <a th:href="@{'../user/toUserList'}">
                                <cite>用户列表</cite>
                            </a>
                        </dd>
                        </dd>
                        <dd class="">
                        <dd class="">
                            <a th:href="@{'../user/toAdminList'}">
                                <cite>管理员管理</cite>
                            </a>
                        </dd>
                        </dd>
                        <dd class="">
                        <dd class="">
                            <a th:href="@{'../user/toRoleList'}">
                                <cite>角色管理</cite>
                            </a>
                        </dd>
                        </dd>
                        <dd class="">
                        <dd class="">
                            <a th:href="@{'../user/toNoteList'}">
                                <cite>短信管理</cite>
                            </a>
                        </dd>
                        </dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a class="javascript:;" href="javascript:;">
                        <i class="layui-icon" style="top: 3px;">&#xe62d;</i><cite>商品管理</cite>
                    </a>
                    <dl class="layui-nav-child">
                        <dd class="">
                        <dd class="">
                            <a th:href="@{'../commodity/toCommodityList'}">
                                <cite>商品列表</cite>
                            </a>
                        </dd>
                        </dd>
                        <dd class="">
                        <dd class="">
                            <a th:href="@{'../commodity/toClassifyList'}">
                                <cite>商品分类</cite>
                            </a>
                        </dd>
                        </dd>
                        <dd class="">
                        <dd class="">
                            <a th:href="@{'../commodity/toTradeTrademarkList'}">
                                <cite>品牌列表</cite>
                            </a>
                        </dd>
                        </dd>
                        <dd class="">
                        <dd class="">
                            <a th:href="@{'../commodity/toMoldList'}">
                                <cite>商品类型</cite>
                            </a>
                        </dd>
                        </dd>
                        <dd class="">
                        <dd class="">
                            <a th:href="@{'../commodity/toParameterList'}">
                                <cite>商品属性</cite>
                            </a>
                        </dd>
                        </dd>
                        <dd class="">
                        <dd class="">
                            <a th:href="@{'../commodity/toPropertyList'}">
                                <cite>参数列表</cite>
                            </a>
                        </dd>
                        </dd>
                        <dd class="">
                        <dd class="">
                            <a th:href="@{'../commodity/toEvaluateList'}">
                                <cite>商品评价</cite>
                            </a>
                        </dd>
                        </dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a class="javascript:;" href="javascript:;">
                        <i class="layui-icon" style="top: 3px;">&#xe634;</i><cite>订单管理</cite>
                    </a>
                    <dl class="layui-nav-child">
                        <dd class="">
                        <dd class="">
                            <a th:href="@{'../order/orderlist'}">
                                <cite>订单列表</cite>
                            </a>
                        </dd>
                        </dd>
                        <dd class="">
                        <dd class="">
                            <a th:href="@{'../invoice/invoicelist'}">
                                <cite>发货单列表</cite>
                            </a>
                        </dd>
                        </dd>
                        <dd class="">
                        <dd class="">
                            <a th:href="@{'../billoflading/BillListAll'}">
                                <cite>提货单列表</cite>
                            </a>
                        </dd>
                        </dd>
                        <dd class="">
                        <dd class="">
                            <a th:href="@{'../aftersale/aftersalelist'}">
                                <cite>售后单列表</cite>
                            </a>
                        </dd>
                        </dd>
                        <dd class="">
                        <dd class="">
                            <a th:href="@{'../return/returnlist'}">
                                <cite>退货单列表</cite>
                            </a>
                        </dd>
                        </dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a class="javascript:;" href="javascript:;">
                        <i class="layui-icon" style="top: 3px;">&#xe642;</i><cite>运营管理</cite>
                    </a>
                    <dl class="layui-nav-child">
                        <dd class="">
                        <dd class="">
                            <a th:href="@{'../Article/Articlelist'}">
                                <cite>文章列表</cite>
                            </a>
                        </dd>
                        </dd>
                        <dd class="">
                        <dd class="">
                            <a th:href="@{'../notice/noticelist'}">
                                <cite>公告列表</cite>
                            </a>
                        </dd>
                        </dd>
                        <dd class="">
                        <dd class="">
                            <a th:href="@{'../ArticleType/ArticleTypelist'}">
                                <cite>文章分类</cite>
                            </a>
                        </dd>
                        </dd>
                        <dd class="">
                        <dd class="">
                            <a th:href="@{'../Advertising/Advertisinglist'}">
                                <cite>广告列表</cite>
                            </a>
                        </dd>
                        </dd>
                        <dd class="">
                        <dd class="">
                            <a th:href="@{'../Advertisingspace/Advertisingspacelist'}">
                                <cite>广告位列表</cite>
                            </a>
                        </dd>
                        </dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a class="javascript:;" href="javascript:;">
                        <i class="layui-icon" style="top: 3px;">&#xe630;</i><cite>促销管理</cite>
                    </a>
                    <dl class="layui-nav-child">
                        <dd class="">
                            <a th:href="@{'../promotion/seckillList'}">
                                <cite>团购秒杀列表</cite>
                            </a>
                        </dd>
                        <dd class="">
                            <a th:href="@{'../coupon/couponList'}">
                                <cite>优惠券列表</cite>
                            </a>
                        </dd>
                        <dd class="">
                            <a th:href="@{'../sales/salesList'}">
                                <cite>促销列表</cite>
                            </a>
                        </dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a class="javascript:;" href="javascript:;">
                        <i class="layui-icon" style="top: 3px;">&#xe606;</i><cite>财务管理</cite>
                    </a>
                    <dl class="layui-nav-child">
                        <dd class="">
                            <a th:href="@{'../paylist'}">
                                <cite>支付单列表</cite>
                            </a>
                        </dd>
                        <dd class="">
                            <a th:href="@{'../withdlist'}">
                                <cite>提现列表</cite>
                            </a>
                        </dd>
                        <dd class="">
                            <a th:href="@{'../metlist'}">
                                <cite>支付方式列表</cite>
                            </a>
                        </dd>
                        <dd class="">
                            <a th:href="@{'../retlist'}">
                                <cite>退款单列表</cite>
                            </a>
                        </dd>
                        <dd class="">
                            <a th:href="@{'../acclist'}">
                                <cite>账户资金管理</cite>
                            </a>
                        </dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a class="javascript:;" href="javascript:;">
                        <i class="layui-icon" style="top: 3px;">&#xe612;</i><cite>控制面板</cite>
                    </a>
                    <dl class="layui-nav-child">
                        <dd class="">
                            <a th:href="@{'../explist'}">
                                <cite>导入导出</cite>
                            </a>
                        </dd>
                        <dd class="">
                            <a th:href="@{'../piclist'}">
                                <cite>图片列表</cite>
                            </a>
                        </dd>
                        <dd class="">
                            <a th:href="@{'../stolist'}">
                                <cite>门店列表</cite>
                            </a>
                        </dd>
                        <dd class="">
                            <a th:href="@{'../log/loglist'}">
                                <cite>操作日志</cite>
                            </a>
                        </dd>
                        <dd class="">
                            <a th:href="@{'../logisticsCompany/getLogistics'}">
                                <cite>物流公司列表</cite>
                            </a>
                        </dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a class="javascript:;" href="javascript:;">
                        <i class="layui-icon" style="top: 3px;">&#xe613;</i><cite>微信管理</cite>
                    </a>
                    <dl class="layui-nav-child">
                        <dd class="">
                            <a th:href="@{'../official/getOfficial'}">
                                <cite>公众号配置</cite>
                            </a>
                        </dd>
                        <dd class="">
                            <a th:href="@{'../official/getApplet'}">
                                <cite>小程序配置</cite>
                            </a>
                        </dd>
                    </dl>
                </li>
            </ul>
        </div>

    </div>
    <div class="layui-tab layui-tab-card site-demo-title x-main" lay-filter="x-tab" lay-allowclose="true" >
        <div class="x-slide_left"></div>
        <!-- <ul class="layui-tab-title">
             <li class="layui-this">
                 我的桌面
                 <i class="layui-icon layui-unselect layui-tab-close">ဆ</i>
             </li>
         </ul>-->
        <div class="x-nav">
            <span class="layui-breadcrumb" style="visibility: visible;">
                <a href="">会员管理</a><span lay-separator="">/</span>
                <a th:href="@{'toUserList'}">用户列表</a><span lay-separator="">/</span>
                <a href="">用户信息修改</a>
            </span>
            <a class="layui-btn layui-btn-primary" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
                <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
            </a>
        </div>
        <div id="b">
        <a class="layui-btn layui-btn-sm" th:href="@{'toUpdateInviterPhone?id='+${session.user.id}}">邀请人修改</a>
        <a class="layui-btn layui-btn-sm" th:href="@{'toUserIntegral?id='+${session.user.id}}">积分修改</a>
        <a class="layui-btn layui-btn-sm" th:href="@{'toUpdateUserBalance?id='+${session.user.id}}">余额修改</a>
        </div>
        <form action="toUserUpdate" method="post" id="form">
            <table>
                <h2 id="a">用户信息修改</h2>
                <tr>
                    <td>id:</td>
                    <td><input type="text" id="id" name="id"  autocomplete="off" class="layui-input" readonly th:value="${session.user.id}"></td>
                </tr>
                <tr>
                    <td>手机号:</td>
                    <td><input type="text" id="userPhone" name="userPhone" th:id="userPhone" autocomplete="off" class="layui-input" th:value="${session.user.userPhone}"></td>
                </tr>
                <tr>
                    <td>昵称:</td>
                    <td><input type="text" id="username" name="username"  autocomplete="off" class="layui-input" th:value="${session.user.username}"></td>
                </tr>
                <tr>
                    <td>性别:</td>
                    <td><select name="userSex" id="userSex" style="padding: 7px">
                        <option value="1" th:selected="${session.user.userStatus==1}">男</option>
                        <option value="2" th:selected="${session.user.userStatus==2}">女</option>
                    </select></td>
                </tr>
                <tr>
                    <td>生日:</td>
                    <td><input type="text" name="userBirthday" id="userBirthday" class="layui-input" th:value="${session.user.userBirthday}"></td>
                </tr><tr>
                <td>状态:</td>
                <td><select name="userStatus"  id="userStatus" style="padding: 7px">
                    <option value="1" th:selected="${session.user.userStatus==1}">可用</option>
                    <option value="2" th:selected="${session.user.userStatus==2}">禁用</option>
                    </select></td>
                </tr>
                <tr>
                    <td>图片:</td>
                    <td><img id="photoimg" th:src="@{'/Path/'+${session.user.userImgPath}}" height="80"></td>
                </tr>
                <tr>
                    <td>重新上传:</td>
                    <td>&nbsp;&nbsp;&nbsp;<input type="button" value="拍摄" class="layui-btn layui-btn-sm" onclick = "openDialog()">
                        <input type="hidden" value="" name="imgfiles">
                    </td>
                </tr>
                <tr>
                    <td> <button class="layui-btn layui-btn-sm" type="submit">修改</button></td>
                </tr>

            </table>
        </form>
        </div>
    <div class="site-mobile-shade">
    </div>
</div>
<script src="../lib/layui/layui.js" charset="utf-8"></script>
<script src="../js/x-admin.js"></script>
<script th:src="@{/webjars/jquery/3.3.1/jquery.min.js}"></script>
<script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
    $(function () {
        $("#form").submit(function () {
            var userPhone=$("#userPhone").val();
            var username=$("#username").val();
            var userBirthday=$("#userBirthday").val();
            var img=$("[name=imgfiles]").val();
            alert(img);
            if(userPhone=="" ||userPhone==null){
                alert("手机号码不能为空!");
                return false;
            }else if(username=="" ||username==null) {
                alert("昵称不能为空!");
                return false;
            }else if(userPassword=="" ||userPassword==null) {
                alert("密码不能为空!");
                return false;
            }else if(!(/^1[34578]\d{9}$/.test(userPhone))){
                alert("手机号码格式有误!");
                return false;
            }else if(!(/^(?![A-Z]+$)(?![a-z]+$)(?!\d+$)\S{8,}$/).test(userPasswordNew)){
                alert("密码格式错误!密码必须符合由数字,大写字母,小写字母,至少其中两种组成，且长度不小于8，同时第一位不能为数字.")
                return false;
            }
        });

        $("#userPhone").change(function(){
            var userPhone=$("#userPhone").val();
            $.getJSON("chackUserPhone","userPhone="+userPhone,function(data){
                if(data.checking=="exists"){
                    alert("该手机已被注册");
                }
            });
        });
    });
</script>


<div id="light" class="white_content" style="text-align: center">
    <button onClick="saveFile(filename);" type="button" id="que" style="display: none">确定</button>
    <video id="v" style="width: 450px;height: 300px;"></video><br>
    <canvas id="canvas" style="display:none;"></canvas>
    <img src="" id="photo" alt="暂无照片" style="height: 100px;width:130px;border: 1px black solid"/>
    <img src="" id="img" style="display:none;">
    <button id="take" class="layui-btn layui-btn-fluid">拍照</button>
    <a href = "javascript:void(0)" onclick = "closeDialog()">点这里关闭本窗口</a>

</div>
<div id="fade" class="black_overlay"></div>
</body>
<script type="text/javascript">
    $(function(){
        $("#take").click(function () {
            var photo=$("#photo").attr("src");
            $("#photoimg").attr("src",photo);
            document.getElementById('que').click();
        })


    });
    function openDialog(){
        document.getElementById('light').style.display='block';
        document.getElementById('fade').style.display='block'
    }
    function closeDialog(){
        document.getElementById('light').style.display='none';
        document.getElementById('fade').style.display='none'
    }
</script>


<script>
    !(function () {
        // 老的浏览器可能根本没有实现 mediaDevices，所以我们可以先设置一个空的对象
        if (navigator.mediaDevices === undefined) {
            navigator.mediaDevices = {};
        }
        if (navigator.mediaDevices.getUserMedia === undefined) {
            navigator.mediaDevices.getUserMedia = function (constraints) {
                // 首先，如果有getUserMedia的话，就获得它
                var getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;

                // 一些浏览器根本没实现它 - 那么就返回一个error到promise的reject来保持一个统一的接口
                if (!getUserMedia) {
                    return Promise.reject(new Error('getUserMedia is not implemented in this browser'));
                }

                // 否则，为老的navigator.getUserMedia方法包裹一个Promise
                return new Promise(function (resolve, reject) {
                    getUserMedia.call(navigator, constraints, resolve, reject);
                });
            }
        }
        const constraints = {
            video: true,
            audio: false
        };
        let videoPlaying = false;
        let v = document.getElementById('v');
        let promise = navigator.mediaDevices.getUserMedia(constraints);
        promise.then(stream => {
            // 旧的浏览器可能没有srcObject
            if ("srcObject" in v) {
            v.srcObject = stream;
        } else {
            // 防止再新的浏览器里使用它，应为它已经不再支持了
            v.src = window.URL.createObjectURL(stream);
        }
        v.onloadedmetadata = function (e) {
            v.play();
            videoPlaying = true;
        };
    }).catch(err => {
            console.error(err.name + ": " + err.message);
    })
        document.getElementById('take').addEventListener('click', function () {
            if (videoPlaying) {
                let canvas = document.getElementById('canvas');
                canvas.width = v.videoWidth;
                canvas.height = v.videoHeight;
                canvas.getContext('2d').drawImage(v, 0, 0);
                let data = canvas.toDataURL('image/webp');
                document.getElementById('photo').setAttribute('src', data);
            }
        }, false);
    })();
</script>

<script th:src="@{/webjars/jquery/3.3.1/jquery.min.js}"></script>
<script type="text/javascript">


    //下面的代码是保存canvas标签里的图片并且将其按一定的规则重命名
    var type = 'png';

    var _fixType = function(type) {
        type = type.toLowerCase().replace(/jpg/i, 'jpeg');
        var r = type.match(/png|jpeg|bmp|gif/)[0];
        return 'image/' + r;
    };
    /**
     * @param  {String} filename 文件名
     */
    var saveFile = function(filename){
        //获取canvas标签里的图片内容
        var imgData = document.getElementById('canvas').toDataURL(type);
        imgData = imgData.replace(_fixType(type),'image/octet-stream');

        var save_link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');
        save_link.href = imgData;
        save_link.download = filename;

        var event = document.createEvent('MouseEvents');
        event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
        save_link.dispatchEvent(event);
    };

    // 下载后的文件名规则
    var filename = (new Date()).getTime() + '.' + type;
        $("[name=imgfiles]").attr("value",filename);
</script>
</body>
</html>
